package cn.kgc.springbootdemo.controller;

import cn.kgc.springbootdemo.entity.User;
import cn.kgc.springbootdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@RestController
@Controller
public class HomeController {

    @Autowired
    private UserService userService;


    @RequestMapping("/")
    public String home(Model model){
        List<User> users = userService.selectUserAll();
        for (User u:users) {
            System.out.println(u.getName());
        }
        model.addAttribute("users",users);
        return "home";
    }
}
